package com.deparse.mydialog.animation;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.deparse.mydialog.R;
import com.deparse.mydialog.common.BaseActivity;
import com.deparse.mydialog.view.RippleLayout;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/7/18.
 */
public class AndroidAnimation extends BaseActivity {
    private ListView listView;
    private AdapterList adapterList;
    private List<String> listData = new ArrayList<>();
    private LayoutInflater layoutInflater;
    private TextView animation;
    private ImageView image;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_android_animation);
        layoutInflater = LayoutInflater.from(this);
        listView = (ListView) findViewById(R.id.listView);
        animation = (TextView) findViewById(R.id.animation);
      RippleLayout ripple= (RippleLayout) findViewById(R.id.ripple);
        animation.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

//                View dialog = layoutInflater.inflate(R.layout.loding_animation, null);
//                new AlertDialog.Builder(AndroidAnimation.this).setView(dialog).show();
//                image = (ImageView) dialog.findViewById(R.id.image);
//                AnimationDrawable frameAnimation = (AnimationDrawable) image.getBackground();
//                frameAnimation.start();

//                startActivity(AnimationGif.class);
            }
        });

        listData.add("Translation");
        listData.add("AlphaScaleXY");
        listData.add("alpha");
        listData.add("rotation");
        listData.add("ScaleXY");
        listData.add("All");

        adapterList = new AdapterList();
        listView.setAdapter(adapterList);
        final Intent intent = new Intent();

        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                switch (position) {
                    case 0:
                        intent.setClass(AndroidAnimation.this, TranslationAnimationActivity.class);
                        startActivity(intent);
                        break;
                    case 1:
                        intent.setClass(AndroidAnimation.this, AlphaScalexyAnimationActivity.class);
                        startActivity(intent);
                        break;
                    case 2:
                        intent.setClass(AndroidAnimation.this, AlphaAnimationActivity.class);
                        startActivity(intent);
                        break;
                    case 3:
                        intent.setClass(AndroidAnimation.this, RotationAnimationActivity.class);
                        startActivity(intent);
                        break;
                    case 4:
                        intent.setClass(AndroidAnimation.this, ScaleAnimationActivity.class);
                        startActivity(intent);
                        break;
                    case 5:
                        intent.setClass(AndroidAnimation.this, AllBaseAnimationActivity.class);
                        startActivity(intent);
                        break;
                }
            }
        });
    }

    private class AdapterList extends BaseAdapter {

        @Override
        public int getCount() {
            return listData.size();
        }

        @Override
        public Object getItem(int position) {
            return listData.get(position);
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            convertView = layoutInflater.inflate(R.layout.item_main_list, null);
            TextView activity_name = (TextView) convertView.findViewById(R.id.activity_name);
            activity_name.setText(listData.get(position));
            return convertView;
        }
    }
}
